﻿using FarmerJoe.ClassSettings;
using FarmerJoe.Helpers;
using Styx;
using Styx.CommonBot;
using Styx.TreeSharp;
using Styx.WoWInternals.WoWObjects;

namespace FarmerJoe.Classes
{
    public static partial class Priest
    {
        private static LocalPlayer Me { get { return StyxWoW.Me; } }
        private static WoWUnit CT { get { return Me.CurrentTarget; } }

        #region Specialisation Switchs
        // Determine which routine to use based on your specialisation
        //
        public static Composite CombatBehavior_SpecSwitch()
        {
            return new PrioritySelector(

                new Switch<WoWSpec>(ret => Me.Specialization,
                                                 new SwitchArgument<WoWSpec>(WoWSpec.PriestDiscipline, CombatBehaviour_Discipline(ClassParser.CCControlledMovement)),
                                                 new SwitchArgument<WoWSpec>(WoWSpec.None, CombatBehaviour_Discipline(true)),
                                                 new SwitchArgument<WoWSpec>(WoWSpec.PriestHoly, CombatBehavior_Holy(ClassParser.CCControlledMovement)),
                                                 new SwitchArgument<WoWSpec>(WoWSpec.PriestShadow, CombatBehavior_Shadow)
                ));
        }

        public static Composite PullBehavior_SpecSwitch()
        {
            return new PrioritySelector(

                new Switch<WoWSpec>(ret => Me.Specialization,
                                                 new SwitchArgument<WoWSpec>(WoWSpec.PriestDiscipline, PullBehavior_Discipline),
                                                 new SwitchArgument<WoWSpec>(WoWSpec.None, PullBehavior_Discipline),
                                                 new SwitchArgument<WoWSpec>(WoWSpec.PriestHoly, PullBehavior_Holy),
                                                 new SwitchArgument<WoWSpec>(WoWSpec.PriestShadow, PullBehavior_Shadow)
                ));
        }
        #endregion


        // Healing. Based on currently specialisation
        public static Composite AllFormsHeal()
        {
            return new PrioritySelector(

                new Decorator(ret => Me.Specialization == WoWSpec.PriestShadow,
                              new PrioritySelector(

                                  Spells.Heal("Vampiric Embrace", ret => Me.HealthPercent < 90),
                                  Spells.Heal("Power Word: Shield", ret=> Me.HealthPercent < 90 && !Me.HasAura("Weakened Soul")),
                                  Spells.Heal("Renew", ret=> Me.HealthPercent < 65 && !Me.HasAura("Renew")),
                                  Spells.Heal("Flash Heal", ret=> Me.HealthPercent < 50)
                                  
                                  )),


                new Decorator(ret => Me.Specialization == WoWSpec.PriestHoly,
                              new PrioritySelector(

                                  Spells.Heal("Power Word: Shield", ret => Me.HealthPercent < 90 && !Me.HasAura("Weakened Soul")),
                                  Spells.Heal("Renew", ret => Me.HealthPercent < 65 && !Me.HasAura("Renew")),
                                  Spells.Heal("Flash Heal", ret => Me.HealthPercent < 50)
                                  
                                  )),


                new Decorator(ret => Me.Specialization == WoWSpec.PriestDiscipline || Me.Specialization == WoWSpec.None,
                              new PrioritySelector(

                                  Spells.Heal("Power Word: Shield", ret => Me.HealthPercent < 90 && !Me.HasAura("Weakened Soul")),
                                  Spells.Heal("Renew", ret => Me.HealthPercent < 65 && !Me.HasAura("Renew")),
                                  Spells.Heal("Flash Heal", ret => Me.HealthPercent < 50)
                                
                                  ))

                );
        }


        // Used by all specs
        public static Composite PreCombatBuffs()
        {
            return new PrioritySelector(

                Spells.WaitForCast(),

                Spells.Buff("Power Word: Fortitude", ret=> Me, ret=> !Me.HasAura("Power Word: Fortitude"),true),


                new Decorator(ret => Me.IsCasting || Me.IsChanneling, new Action(context => RunStatus.Success))

                );
        }



    }
}
